package com.atguigu.srb.core.controller.admin;

import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.pojo.entity.UserInfo;
import com.atguigu.srb.core.pojo.query.UserInfoQuery;
import com.atguigu.srb.core.service.UserInfoService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author lwm1435@163.com
 * @date 2022-02-12 15:00
 * @description
 */
@Api(tags = "会员管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/core/userInfo")
public class AdminUserInfoController {
    @Resource
    private UserInfoService userInfoService;

    @ApiOperation("获取会员分页列表")
    @GetMapping("/list/{pageNo}/{pageSize}")
    public R listPage(@PathVariable Long pageNo, @PathVariable Long pageSize,
                      UserInfoQuery userInfoQuery){
        Page<UserInfo> page = new Page<>(pageNo, pageSize);
        userInfoService.listPage(page,userInfoQuery);

        return R.ok().data("pageModel",page);
    }

    @ApiOperation("锁定和解锁")
    @PutMapping("/lock/{id}/{status}")
    public R lock(@PathVariable Long id, @PathVariable Integer status){

        userInfoService.lock(id,status);

        return R.ok().message(status == 1? "解锁成功":"锁定成功");
    }
}
